class Solution {
public:
    bool _checkSubTree(TreeNode* t1, TreeNode* t2) {
        if (t1 == nullptr && t2 == nullptr) {
            return true; 
        }
        if (t1 == nullptr || t2 == nullptr) {
            return false; 
        }
        return t1->val == t2->val && _checkSubTree(t1->left, t2->left) && _checkSubTree(t1->right, t2->right);
    }

    bool checkSubTree(TreeNode* t1, TreeNode* t2) {
        if (t2 == nullptr) {
            return true;
        }
        if (t1 == nullptr) {
            return false; 
        }
        
        return _checkSubTree(t1, t2) || checkSubTree(t1->left, t2) || checkSubTree(t1->right, t2);
    }
};